import React, {Component} from 'react';
import PropTypes from "prop-types";
import Item from "../Item";
import "./index.css"
class List extends Component {
    // 对接收的props 进行:类型、必要性的限制
    static propTypes = {
        todos: PropTypes.array.isRequired,
        updateTodo: PropTypes.func.isRequired
    }
    // 渲染组件
    render() {
        const {todos,updateTodo,deleteTodo} = this.props;
        return (
            <ul className="todo-main">
                {
                    todos.map(item => <Item key={item.id} {...item}  updateTodo={updateTodo} deleteTodo={deleteTodo}/>)
                }
            </ul>
        );
    }
}

export default List;